package com.two.shopping.mapper;

import com.two.shopping.pojo.Orders;
import com.two.shopping.pojo.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface IOrderMapper {
    //查询用户id为id的订单
    @Select("select * from orders where user_id=#{id}")
    List<Orders> allSelectOrdersId(User user);

    @Select("select * from orders ")
    List<Orders> allSelectOrders();

    //查询为id的订单
    @Select("select * from orders where id=#{id}")
    Orders SelectIdOrders(Orders orders);

    List<Orders> SelectIdOrderss(List<Orders> orders);

    //查看state为完成的订单
    @Select("select  *from orders where state=3 and user_id=#{id}")
    List<Orders> allSelectOrders3(User user);

    //完成订单后吧state修改成4
    @Update("update  orders set state=4 , update_time=#{updateTime} where id=#{id}")
    void Orders4(Orders orders);

    //删除订单
    @Delete("delete from order where  id=#{id}")
    void delete(Integer id);

    //发货
    @Update("update orders set state=2 where id=#{id}")
    void fahuo(Orders orders);

    //收货
    @Update("update orders set state=3 where id=#{id}")
    void shouhuo(Orders orders);
}
